package com.alibaba.citrus.cr.sales.plan.functions.contract;

import com.alibaba.citrus.cr.common.util.SpringContextUtil;
import com.alibaba.citrus.cr.sales.plan.repository.ContractRepository;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.QueryContractRequest;
import com.alibaba.citrus.cr.sales.plan.sdo.ContractSDO;

/**
 * @author wangyibing
 */
public class ContractFactory {
    private static ContractRepository contractRepository;

    static {
        contractRepository = SpringContextUtil.getBean(ContractRepository.class);
    }

    public static ContractEntity load(ContractSDO editContractRequest) {
        QueryContractRequest queryContractRequest = new QueryContractRequest();
        queryContractRequest.setId(String.valueOf(editContractRequest.getId()));
        ContractSDO contractSDO = contractRepository.queryContractById(queryContractRequest);
        return ContractEntity.of(contractSDO);
    }
}
